/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gagnatech.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Dimitri
 */
@Entity
@Table(name = "media")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Media.findAll", query = "SELECT m FROM Media m"),
    @NamedQuery(name = "Media.findByIdmedia", query = "SELECT m FROM Media m WHERE m.idmedia = :idmedia"),
    @NamedQuery(name = "Media.findByResume", query = "SELECT m FROM Media m WHERE m.resume = :resume"),
    @NamedQuery(name = "Media.findByTitle", query = "SELECT m FROM Media m WHERE m.title = :title")})
public class Media implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDMEDIA")
    private Integer idmedia;
    @Size(max = 255)
    @Column(name = "RESUME")
    private String resume;
    @Size(max = 255)
    @Column(name = "TITLE")
    private String title;
    @OneToMany(mappedBy = "mediaIdmedia")
    private List<Loan> loanList;
    @JoinColumn(name = "idGenre", referencedColumnName = "IDGENRE")
    @ManyToOne
    private Genre idGenre;
    @JoinColumn(name = "idAuthor", referencedColumnName = "IDAUTHOR")
    @ManyToOne
    private Author idAuthor;
    @JoinColumn(name = "idCategory", referencedColumnName = "IDCATEGORY")
    @ManyToOne
    private Category idCategory;

    public Media() {
    }

    public Media(Integer idmedia) {
        this.idmedia = idmedia;
    }

    public Integer getIdmedia() {
        return idmedia;
    }

    public void setIdmedia(Integer idmedia) {
        this.idmedia = idmedia;
    }

    public String getResume() {
        return resume;
    }

    public void setResume(String resume) {
        this.resume = resume;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @XmlTransient
    public List<Loan> getLoanList() {
        return loanList;
    }

    public void setLoanList(List<Loan> loanList) {
        this.loanList = loanList;
    }

    public Genre getIdGenre() {
        return idGenre;
    }

    public void setIdGenre(Genre idGenre) {
        this.idGenre = idGenre;
    }

    public Author getIdAuthor() {
        return idAuthor;
    }

    public void setIdAuthor(Author idAuthor) {
        this.idAuthor = idAuthor;
    }

    public Category getIdCategory() {
        return idCategory;
    }

    public void setIdCategory(Category idCategory) {
        this.idCategory = idCategory;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmedia != null ? idmedia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Media)) {
            return false;
        }
        Media other = (Media) object;
        if ((this.idmedia == null && other.idmedia != null) || (this.idmedia != null && !this.idmedia.equals(other.idmedia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gagnatech.entity.Media[ idmedia=" + idmedia + " ]";
    }
    
}
